package ubiqweb.spring3.service;

import java.util.List;


import ubiqweb.spring3.dao.UserDao;
import ubiqweb.spring3.model.LoginDetails;
import ubiqweb.spring3.model.Registration;
import ubiqweb.spring3.model.UserDetails;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("userService")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class UserServiceImpl implements UserService {

	@Autowired
	private UserDao userDao;

	public UserServiceImpl() {
	}

	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
	public void addUser(Registration registration) {
		userDao.saveUser(registration);
	}
	
	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
	public void saveUserDetails(UserDetails userDetails) {
		userDao.saveUserDetails(userDetails);
	}
	
	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
	public void saveLoginDetails( LoginDetails loginDetails ){
		userDao.saveLoginDetails(loginDetails);
		
	}
	
	public List<Registration> listUsers() {
		return userDao.listUsers();
	}
	
	public List<Registration> listUserDetails(String userId) {
		return userDao.listUserDetails(userId);
	}
	
	
	public List<LoginDetails> listLoginDetails(String userId){
		return userDao.listLoginDetails(userId);
	}

}